package com.testpro.java.lambda;

import org.testng.annotations.Test;

import java.util.Arrays;

/**
 * @author Administrator testdevops
 * @description lambda学习
 * @create 2019-07-10 15:44
 */
public class lambdaTest {

  @Test
  public void FirstLambda() {
    Integer x = 1;
    Integer[] y = {1, 2, 2, 3, 4, 5};
    lambdaInterface<Integer> lambdaInterface =
        ((x1, y1) -> {
          final int sum = Arrays.stream(y1).reduce(0, Integer::sum);
          return sum + x1;
        });
    final int sum = lambdaInterface.getSUM(x, y);
    System.out.println(sum);
  }

  @Test
  public void FirstLambdaString() {
    String x = "hello";
    String[] y = {"hello", "hello", "hello"};
    lambdaInterface<String> lambdaInterface =
        (((x1, y1) -> {
          final String s1 = Arrays.toString(y1);
          final String s = x1 + "66666FirstLambdaString66666" + s1;
          return s;
        }));
    final String sum = lambdaInterface.getSUM(x, y);
    System.out.println(sum);
  }
}
